<?php

/**
 * Product filter form base class.
 *
 * @package    corpon
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseProductFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'name'             => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'subtitle'         => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'description'      => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'increment'        => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'status'           => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'highlight'        => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'price'            => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'discount'         => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'discounted_price' => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'photo1'           => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'photo2'           => new sfWidgetFormFilterInput(),
      'photo3'           => new sfWidgetFormFilterInput(),
      'start_date'       => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'end_date'         => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'created_at'       => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'id_account'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Account'), 'add_empty' => true)),
    ));

    $this->setValidators(array(
      'name'             => new sfValidatorPass(array('required' => false)),
      'subtitle'         => new sfValidatorPass(array('required' => false)),
      'description'      => new sfValidatorPass(array('required' => false)),
      'increment'        => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'status'           => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'highlight'        => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'price'            => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'discount'         => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'discounted_price' => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'photo1'           => new sfValidatorPass(array('required' => false)),
      'photo2'           => new sfValidatorPass(array('required' => false)),
      'photo3'           => new sfValidatorPass(array('required' => false)),
      'start_date'       => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
      'end_date'         => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
      'created_at'       => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'id_account'       => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Account'), 'column' => 'id_account')),
    ));

    $this->widgetSchema->setNameFormat('product_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Product';
  }

  public function getFields()
  {
    return array(
      'id_product'       => 'Number',
      'name'             => 'Text',
      'subtitle'         => 'Text',
      'description'      => 'Text',
      'increment'        => 'Number',
      'status'           => 'Boolean',
      'highlight'        => 'Boolean',
      'price'            => 'Number',
      'discount'         => 'Number',
      'discounted_price' => 'Number',
      'photo1'           => 'Text',
      'photo2'           => 'Text',
      'photo3'           => 'Text',
      'start_date'       => 'Date',
      'end_date'         => 'Date',
      'created_at'       => 'Date',
      'id_account'       => 'ForeignKey',
    );
  }
}
